package app.android.com.wuandroidapp.playair;

import java.io.InputStream;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.RectF;


	public class MyBullet {

		Bitmap bitmap;// 图像
		int width, height;// 子弹的尺寸
		float x, y;// 出现的位置
		float speedy;
		float screenWidth, scrreenHeight;// 屏幕大小
		boolean isLive = true;


		public MyBullet(Context context, int resourceID,float x,float y,float speedy) {

			// TODO Auto-generated constructor stub
			// 将图像专场Bitmap
			InputStream is = context.getResources().openRawResource(resourceID);
			bitmap = BitmapFactory.decodeStream(is);

			width = bitmap.getWidth();
			height = bitmap.getHeight();

			this.x=x-width/2;
			this.y=y-height;

			this.speedy=speedy;

		}


// 绘制自身

		public void draw(Canvas canvas) {
			if(isLive){
				canvas.drawBitmap(bitmap, x, y, null);
			}else{
				isLive=false;
			}
		}


		public void move() {

			if (y <-height) {
				isLive = false;
			}
			y += speedy;

		}

		public RectF getBound(){
			RectF rf=new RectF(x,y,x,y-height);
			return rf;
		}
	}
